#include <chrono>
#include <iostream>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include "yolov3_clip_detector.h"
#include "opencv2/opencv.hpp"

int main()
{
    const char * ModelInfPath = "../model/vit_base_patch32_clip_256.om";
    const char * ModelVisPath = "../model/vit_base_patch32_clip_256.om";
    
    Yolov3CLIPDetector sampleProcess(ModelInfPath, ModelVisPath);
    bool ret = sampleProcess.init();
    if (!ret) {
        std::cout<<"sample init resource failed"<<std::endl;
        return 0;
    }

    std::vector<std::string> imageLists;
    float timeSum = 0;
    for (int i=1; i<3; i++){
        std::string imgpath = "../data/" + std::to_string(i) + ".jpg";
        imageLists.push_back(imgpath);
    }
    
    std::vector<message_result> results;
    std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
    for (int i=0;i<100; i++){
        results = sampleProcess.inference(imageLists);
    }
    std::chrono::high_resolution_clock::time_point t2 = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double, std::milli> time_span = t2 - t1;
    std::cout<<"average time: "<<time_span.count()/100<<std::endl;
	
    for(auto data: results){
        std::cout<<"filename: "<<data.filenames[0]<<std::endl;
        std::vector<float> detectData = data.finalOutput[0];
        for(int i=0; i<6; i++){
            std::cout<<detectData[i]<<" ";
        }
        std::cout<<" "<<std::endl;
    }

    return 1;
}



